package com.mebs.model.service.procurement;

import com.mebs.model.AbstractVendor;

import javax.persistence.*;

import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.hibernate.criterion.Projections;

/**
 * Created by Sergey Prasolov, sap@jensentechnologies.com
 * Date: Feb 13, 2006, 4:33:53 PM
 */
@Entity()
@DiscriminatorValue("SUPPLIER")
public class Supplier extends AbstractVendor {
    @Transient
    public boolean isDeletable(Session session)
    {
        return (Integer)session.createCriteria(Quote.class)
            .add(Restrictions.eq("supplier", this))
            .setProjection(Projections.rowCount())
            .uniqueResult() == 0;
    }
}
